#AUTO
MO; 'MOTORS MUST BE OFF TO SET CURRENT
WT 1000
AG*=1; 'CURRENT LEVEL 1.0A
SH; 'TURN MOTORS BACK ON
LU1; 'LCD UPDATE ON
MT*=-2.5; 'STEPPER, ACTIVE HIGH PULSES, REVERSED
CN1,1,1,0,1; 'LIMITS ACTIVE HIGH, DRIVE + WHEN HM IS HIGH
LC*=1; '25% CURRENT AT STANDBY
OE*=0; 'DISABLE OFF-ON ERROR
LD*=0; 'F&R LIMITS ENABLED
ER*=-1; 'DISABLE POSITION ERROR LIMIT
SP*=50000; 'SET SPEED
AC*=128000; 'SET ACCELERATION
DC*=128000; 'SET DECELERATION
HV*=25000; 'HOMING VELOCITY (DEFAULT=256)
IA 192,168,10,81; 'SET IP ADDRESS
POSJOG=40000
NEGJOG=-5000
OSTSAT=0;  'OFFSET FOR SLIT A TOP BLADE
OSTSAB=0;  'OFFSET FOR SLIT A BOTTOM BLADE
OSTSAL=0;  'OFFSET FOR SLIT A LEFT BLADE
OSTSAR=0;  'OFFSET FOR SLIT A RIGHT BLADE
OSTSBT=0;  'OFFSET FOR SLIT B TOP BLADE
OSTSBB=0;  'OFFSET FOR SLIT B BOTTOM BLADE
OSTSBL=0;  'OFFSET FOR SLIT B LEFT BLADE
OSTSBR=0;  'OFFSET FOR SLIT B RIGHT BLADE
EN
'
#HM_A
'
DONEA=0;DONEB=0;DONEC=0;DONED=0
OLDSPA=_SPA;OLDSPB=_SPB;OLDSPC=_SPC;OLDSPD=_SPD
'IF ON +LIMIT, NO NEED TO MOVE
'IF NOT ON +LIMIT JOG TOWARDS +LIMIT
IF(_LFA=1);JGA=POSJOG;BGA;MG "AXIS A - DRIVING TO +LIMIT";ENDIF
IF(_LFB=1);JGB=POSJOG;BGB;MG "AXIS B - DRIVING TO +LIMIT";ENDIF
IF(_LFC=1);JGC=POSJOG;BGC;MG "AXIS C - DRIVING TO +LIMIT";ENDIF
IF(_LFD=1);JGD=POSJOG;BGD;MG "AXIS D - DRIVING TO +LIMIT";ENDIF
'WAIT UNTIL ALL MOTION IS COMPLETE
MC ABCD
'
IF ((_LFA=0)&(_LFB=0)&(_LFC=0)&(_LFD=0))
MG "ALL AXES ON +LIMITS"
ELSE
MG "ONE OR MORE AXIS NOT ON +LIMIT"
ENDIF
'
JGA=NEGJOG;JGB=NEGJOG;JGC=NEGJOG;JGD=NEGJOG
BG ABCD
MG "ALL AXES MOVING OFF +LIMITS"
'
#KPONA
IF((_LFA=1)&(DONEA=0));DONEA=1;STA;MG "AXIS A - +LIMIT FOUND";ENDIF
IF((_LFB=1)&(DONEB=0));DONEB=1;STB;MG "AXIS B - +LIMIT FOUND";ENDIF
IF((_LFC=1)&(DONEC=0));DONEC=1;STC;MG "AXIS C - +LIMIT FOUND";ENDIF
IF((_LFD=1)&(DONED=0));DONED=1;STD;MG "AXIS D - +LIMIT FOUND";ENDIF
JP#KPONA,(DONEA=0)|(DONEB=0)|(DONEC=0)|(DONED=0)
MC ABCD
DPA=0;DPB=0;DPC=0;DPD=0
'
PAA=-2500000+OSTSAB;SPA=60000
PAB=-2500000+OSTSAT;SPB=60000
PAC=-2500000+OSTSAR;SPC=60000
PAD=-2500000+OSTSAL;SPD=60000
BG ABCD
MC ABCD
DPA=0;DPB=0;DPC=0;DPD=0
SPA=OLDSPA;SPB=OLDSPB;SPC=OLDSPC;SPD=OLDSPD
'
EN
'
#HM_B
'
DONEE=0;DONEF=0;DONEG=0;DONEH=0
OLDSPE=_SPE;OLDSPF=_SPF;OLDSPG=_SPG;OLDSPH=_SPH
'IF ON +LIMIT, NO NEED TO MOVE
'IF NOT ON +LIMIT JOG TOWARDS +LIMIT
IF(_LFE=1);JGE=POSJOG;BGE;MG "AXIS E - DRIVING TO +LIMIT";ENDIF
IF(_LFF=1);JGF=POSJOG;BGF;MG "AXIS F - DRIVING TO +LIMIT";ENDIF
IF(_LFG=1);JGG=POSJOG;BGG;MG "AXIS G - DRIVING TO +LIMIT";ENDIF
IF(_LFH=1);JGH=POSJOG;BGH;MG "AXIS H - DRIVING TO +LIMIT";ENDIF
'WAIT UNTIL ALL MOTION IS COMPLETE
MC EFGH
'
IF ((_LFE=0)&(_LFF=0)&(_LFG=0)&(_LFH=0))
MG "ALL AXES ON +LIMITS"
ELSE
MG "ONE OR MORE AXIS NOT ON +LIMIT"
ENDIF
'
JGE=NEGJOG;JGF=NEGJOG;JGG=NEGJOG;JGH=NEGJOG
BG EFGH
MG "ALL AXES MOVING OFF +LIMITS"
'
#KPONB
IF((_LFE=1)&(DONEE=0));DONEE=1;STE;MG "AXIS E - +LIMIT FOUND";ENDIF
IF((_LFF=1)&(DONEF=0));DONEF=1;STF;MG "AXIS F - +LIMIT FOUND";ENDIF
IF((_LFG=1)&(DONEG=0));DONEG=1;STG;MG "AXIS G - +LIMIT FOUND";ENDIF
IF((_LFH=1)&(DONEH=0));DONEH=1;STH;MG "AXIS H - +LIMIT FOUND";ENDIF
JP#KPONB,(DONEE=0)|(DONEF=0)|(DONEG=0)|(DONEH=0)
MC EFGH
DPE=0;DPF=0;DPG=0;DPH=0
'
PAE=-2500000+OSTSBB;SPE=60000
PAF=-2500000+OSTSBT;SPF=60000
PAG=-2500000+OSTSBR;SPG=60000
PAH=-2500000+OSTSBL;SPH=60000
BG EFGH
MC EFGH
DPE=0;DPF=0;DPG=0;DPH=0
SPE=OLDSPE;SPF=OLDSPF;SPG=OLDSPG;SPH=OLDSPH
'
EN
